//
//  UIBarButtonItem+Extension.m
//  sina
//
//  Created by apple on 15/10/23.
//  Copyright © 2015年 90Chuang. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"
#import "UIView+Extension.h"

@implementation UIBarButtonItem (Extension)

// 创建一个item
// target : 点击item后调用哪个对象的方法
// action : 点击item后调用target的那个方法
// image : 图片
// highImage : 高亮图片

// return : 返回创建的item
+ (UIBarButtonItem *)itemWithTarget:(id)taget action:(SEL)action image:(NSString *)image highImage:(NSString *)highimage
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn addTarget:taget action:action forControlEvents:UIControlEventTouchUpInside];
    
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:highimage] forState:UIControlStateHighlighted];
    btn.size = btn.currentBackgroundImage.size;
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}
@end




